#ifndef CRATE_APP_H
#define CRATE_APP_H

//=============================================================================
//
// Demonstrates texturing.
//
//=============================================================================

#include "d3dApp.h"
#include "Crate.h"
#include "Light.h"

#include <cstdint>

namespace D3D10
{
	class CrateApp : public D3DApp
	{
	public:
		CrateApp(const HINSTANCE hInstance);
		~CrateApp();
	
		void initApp();
		void onResize();
		void updateScene(const float deltaTime);
		void drawScene(); 
	
	private:
		void buildFX();
		void buildVertexLayouts();
	
	private:	
		static const float sDeltaForTextureChange = 17.0f * 30.0f;aS1 
		static const uint8_t mNumberOfTextures = 120;

		D3D10Utils::Crate mCrateMesh;

		D3DXMATRIX mView;
		D3DXMATRIX mProjection;
		D3DXMATRIX mWVP;
		D3DXMATRIX mCrateWorld;
		D3DXMATRIX mTextureMatrix;

		D3DXVECTOR3 mEyePos;

		D3D10Utils::Light mParallelLight;

		ID3D10Effect *mEffect;
		ID3D10EffectTechnique *mTechnique;
		ID3D10InputLayout *mVertexLayout;
		ID3D10EffectMatrixVariable *mEffectWVPVariable;
		ID3D10EffectMatrixVariable *mEffectWorldVariable;
		ID3D10EffectMatrixVariable *mEffectTexMtxVariable;

		ID3D10EffectVariable *mEffectEyePosVariable;
		ID3D10EffectVariable *mEffectLightVariable;
		
		ID3D10ShaderResourceView *mDiffuseMapRV[mNumberOfTextures];
		ID3D10ShaderResourceView *mSpecularMapRV;

		ID3D10EffectShaderResourceVariable *mEffectDiffuseMapVariable;
		ID3D10EffectShaderResourceVariable *mEffectExtraDiffuseMapVariable;
		ID3D10EffectShaderResourceVariable *mEffectSpecularMapVariable;
	
		float mTheta;
		float mPhi;
		float mRadius;

		float mDeltaForTextureChange;

		uint8_t mTextureIndex;
	};
}

#endif // CRATE_APP_H
